using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using B.S.ReportEvent.Domain.Entities;
using B.S.ReportEvent.ErrorCode.ErrorCodes;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using B.S.ReportEvent.ApiNew.Commands.Records;
using B.S.ReportEvent.ApiNew.Dtos.RequestDto;
using System.Security.Claims;
using B.S.ReportEvent.ErrorCode;

namespace B.S.ReportEvent.ApiNew.Controllers
{
    /// <summary>
    /// 工作流审批记录控制器
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    public class RecordsController : ControllerBase
    {
        /// <summary>
        /// 日志
        /// </summary>
        private readonly ILogger<RecordsController> _logger;

        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator _mediator;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="mediator"></param>
        public RecordsController(ILogger<RecordsController> logger, IMediator mediator)
        {
            _logger = logger;
            _mediator = mediator;
        }

        /// <summary>
        /// 新增审批记录
        /// </summary>
        /// <param name="dto">请求数据</param>
        /// <returns>结果</returns>
        [HttpPost("ProcessRecordInsert")]
        public async Task<ApiResult> ProcessRecordInsert([FromBody] ProcessRecordInsertCommand request)
        {
            // 发送命令
            return await _mediator.Send(request);
        }
    }
}